package com.forekonw.demo12;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * 从控制台输入3次学生的信息(编号,姓名,年龄,电话号码)
 * 将这三个学生的信息写到文件中(student.txt)
 * 数据的格式:  1001 tom  23  13464001234
 *             1002 tony 22  13464001234
 *             1003 jim  24  13464001234
 * 要求从文件当中读取所以学生信息并输出
 *    功能类(1写,2读)
 */
public class test {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        List<Student> s = new ArrayList<>();
        for (int i = 0 ; i<3;i++){
            System.out.println("请输入学生编号");
            String num = input.next();
            System.out.println("请输入学生姓名");
            String name = input.next();
            System.out.println("请输入学生年龄");
            String age = input.next();
            System.out.println("请输入学生电话号码");
            String tel = input.next();
            Student student = new Student(num,name,age,tel);
            s.add(student);
        }
        //调用功能写入
        //调用功能读取
        ReadWrite rw = new ReadWrite();
        rw.write(s,"student");
        List<Student> students = rw.read("student");
        for (Student sss:students) {
            System.out.println(sss.getNum()+" "+sss.getName()+" "+sss.getAge()+" "+sss.getTel());
        }
    }
}
